package mx.com.mindbits.bandpay;



import mx.com.mindbits.bandpay.fragments.ContactsSettingsFragments;
import mx.com.mindbits.bandpay.fragments.UserSettingsFragment;
import mx.com.mindbits.bandpay.utils.TabsAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;

public class UserSettings extends SherlockFragmentActivity{
	private ViewPager viewPager;
	private TabsAdapter tabsAdapter;
	private ActionBar actionBar;
	private Intent intent;
	@Override
	public void onCreate(Bundle savedInstanceBundle){
		super.onCreate(savedInstanceBundle);
		
		viewPager = new ViewPager(this);
		viewPager.setId(R.id.pager);
		
		actionBar = getSupportActionBar();
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setDisplayShowHomeEnabled(true);
		
		tabsAdapter = new TabsAdapter(this, viewPager);
		tabsAdapter.addTab(actionBar.newTab().setText(R.string.label_fragment_user), UserSettingsFragment.class, null);
		tabsAdapter.addTab(actionBar.newTab().setText(R.string.label_fragment_contacts),
				ContactsSettingsFragments.class, null);
		intent = getIntent();
		
		if(intent.getBooleanExtra("tab",false) ){
			viewPager.setCurrentItem(1);
		}
		setContentView(viewPager);
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item){
		switch(item.getItemId()){
		case android.R.id.home:
			Intent intent = new Intent(this, MainMenuActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
			break;
		}
		return true;
	}
}
